package dayong.com;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.gson.Gson;

import conn.Connection1;
import conn.img;

/**
 * Servlet implementation class showDetailsImg
 */
@WebServlet(description = "图片详情", urlPatterns = { "/showDetailsImg" })
public class showDetailsImg extends HttpServlet {
	private static final long serialVersionUID = 1L;
	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		int id = Integer.parseInt( request.getParameter("id"));
		System.out.println(id);
		Connection1 conn = new Connection1();
		// 查询选中的图片
		List<img> list = conn.findCurrImg(id);
		Gson gson= new Gson();
		String json = gson.toJson(list);
		//System.out.println(json);
		// 返回list
		request.setAttribute("list", list);
		request.setAttribute("json", json);
		request.getRequestDispatcher("detailsImg.jsp").forward(request, response);
		
	}
}
